package com.ssm.Dao;

import com.ssm.Utils.DBCPUtils;

import java.sql.ResultSet;
import java.sql.SQLException;

public class showNumberDao {

    public int showNumber(String name){

        String sql="select c_number from shop where u_id in(select id from user where name=?)";

        int num=0;

        Object[] objects={name};
        ResultSet resultSet = DBCPUtils.executeQuery(sql,objects);

        try {
            while (resultSet.next()){

                num+=resultSet.getInt("c_number");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            //关闭数据库的方法
            DBCPUtils.closeAll(resultSet, DBCPUtils.pstmt, DBCPUtils.connection);
        }
        return num;
    }

}
